ELEVATOR_CHANNEL = 1
ELEVATOR_FLOORS_CHANNEL = 2

modem = peripheral.wrap("left")	
modem.open(ELEVATOR_FLOORS_CHANNEL)

function main()
	while true do
		event, param1, param2, param3, param4, param5 = os.pullEvent()
		if event == "modem_message" then
			local new_level = tonumber(param4)
			if 0 <= new_level and new_level <= 4 then
				print("repeating "..new_level)
				modem.transmit(ELEVATOR_CHANNEL, ELEVATOR_CHANNEL, new_level)
			end
		end
	end
end

main()
modem.close()